home *** CD-ROM | disk | FTP | other *** search
- Path: thor.tu.hac.com!collins
- From: collins@thor.tu.hac.com (Ron Collins)
- Newsgroups: comp.lang.c
- Subject: Re: Strcat Doesn't work for this?
- Date: 15 Jan 1996 13:58:34 GMT
- Organization: Advanced Depot Systems
- Message-ID: <4ddmia$a1j@hacgate2.hac.com>
- References: <Pine.SOL.3.91.960111151925.25068C-100000@lore.cs.purdue.edu>
- NNTP-Posting-Host: thor.tu.hac.com
-
- ** Craig Cook ** (cookca@cs.purdue.edu) wrote:
- : Here is my excerpt of code in question:
-
-
- : Putword(int w, char *imageChar)
- : {
- : w = (w & 0xff);
- : strcat( imageChar, (const char *)w );
-
- : }
-
- : Why does it core dump? It should work right?
-
- : Craig
- : ,,,
-
-
- Forget all this tricky stuff. The cast on "w" is wrong, and depends upon
- the "endianess" of your machine. Just do it the simple way:
-
-
- void Putword(int w, char *imageChar) {
- unsigned char temp[2];
-
- temp[0] = (char) w;
- temp[1] = 0;
-
- strcat(imageChar, temp);
- }
-
-
-
- -- Collins --
-
- -----
- The views expressed here are mine alone.
-
- Ron Collins/Hughes Aircraft Company/M20,P20/Tucson Az 85706
- rcollins@thor.tu.hac.com collins@seagull.rtd.com
- ยก----
-